<?php
define('INWEB', True);
chdir('..');
require_once("include/config.php");
//пароль
$tr_id=getConfig('settings','transport_id', '1'); //Transporta ID
if(isset($_GET['obj_type']) && is_numeric($_GET['obj_type']) && $user->logged())
{
	$obj_type=getVar('obj_type');
    if($obj_type!=$tr_id)
    {
    	$objquery=$sql->query("SELECT id, loc, cta_person, `desc` FROM objects WHERE `tId`='$obj_type'");
    	if($sql->num_rows($objquery))
    	{
   		    echo "obj.options[obj.options.length] = new Option('','');\n";
    		while($option = $sql->fetch_array($objquery))
    		{
                $option['cta_person']=str_replace("&","&amp;", $option['cta_person']);
                $option['desc']=str_replace("&","&amp;", $option['desc']);
    			echo "obj.options[obj.options.length] = new Option('{$option['loc']}\t|\t{$option['cta_person']}\t|\t{$option['desc']}','{$option['id']}');\n";
    		}
    	}
    }
    else
    {
   	    $objquery=$sql->query("SELECT id, reg_nr, manufacturer, model FROM objects WHERE `tId`='$tr_id';");
    	if($sql->num_rows($objquery))
    	{
    	    echo "obj.options[obj.options.length] = new Option('','');\n";
    		while($option = $sql->fetch_array($objquery))
    		{
    			echo "obj.options[obj.options.length] = new Option('{$option['reg_nr']}\t|\t{$option['manufacturer']}\t|\t{$option['model']}','{$option['id']}');\n";
    		}
    	}
    }
}
else
{
	die('Missing vars or not logged');
}
?>